<template>
	<view class="box">
		<view class="tips">
			注销账号将放弃以下权益
		</view>
		<view class="txt">
			<view class="send">
				<text>1.</text>
				<text> 系统将清空您智初小交所有信息、包括但不限于账户信息、身份信息、充值交易记录等。</text>
			</view>
			<view class="send">
				<text>2.</text>
				<text>电子钱包的快捷支付服务不能提供服务。</text>
			</view>
			<view class="fend">
				<text> </text>
				<text>以上信息和功能将永久清除，不可恢复</text>
			</view>
		</view>
		<view class="warn">
			<view class="img">
				<image src="/static/images/blank/attention.png" mode=""></image>
			</view>
			<view class="right">
				温馨提示：系统检测到您的智初小交账号下还存在电子钱
				包，不能注销账号，为保证您的各项权益，请您先对电子
				钱包销户后再进行智初小交的注销账号操作。
			</view>
		</view>
		<view v-if="able" class="xieyi">

			<view :class="sign?'crcle':'crcle2'" @click="myArgee">
			</view>
			<view class="one">
				已阅读并同意
			</view>
			<view class="two" @click="knowUser">
				《账号注销须知》
			</view>
		</view>
		<view class="btn">
			<view :class="btnOff?'reallyBtn':'checkBtn'" @click="toIndex">
				申请注销账号
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getPhoneCode,
		getTwoUserList,
		getMoneny,
		bindTwoEmpStu,
		TwoUserBinded,
		TwoUserBindStuList,
		DeleteUser
	} from '../../common/api/blank.js';
	export default {
		data() {
			return {
				sign: true,
				btnOff: true,
				able: false
			}
		},
		async onShow() {
			uni.showLoading({
				title: "检测账户中"
			})
			let s_userId = uni.getStorageSync("s_userId");
			const res = await getTwoUserList({
				userId: s_userId
			})
			console.log(res)
			if (res.code == 0) {
				if (res.data.length > 0) {
					uni.hideLoading()
					this.able = false
				} else {
					uni.hideLoading()
					this.able = true
				}
			} else {
				uni.hideLoading()
				uni.showToast({
					icon: 'none',
					title: res.msg
				})
			}
		},
		components: {

		},
		onBackPress(options) {
			if (options.from === 'navigateBack') {
				return false
			}
			this.back();
			return true
		},
		methods: {
			knowUser(){
				uni.navigateTo({
					url:"/pageBlank/components/agreement?url=removeAccount.html&title=账号注销须知"
				})
			},
			myArgee() {
				this.sign = !this.sign
				this.btnOff = !this.btnOff
			},
			back() {
				var pages = getCurrentPages();
				uni.navigateBack()
			},
			toIndex() {
				if (!this.btnOff) {
					var userId = uni.getStorageSync('s_userId')
					var mobileNo = uni.getStorageSync("s_mobile")
					uni.showLoading({
						title:"注销中"
					})
					DeleteUser("", `userId=${userId}&mobileNo=${mobileNo}`).then((res) => {
						console.log(res)
						if (res.code == 0) {
							uni.hideLoading()
							uni.showToast({
								title: '注销成功~'
							})
							uni.removeStorage({
								key: 's_login'
							})
							uni.removeStorage({
								key: 's_userId'
							})
							uni.removeStorage({
								key: 'realname'
							})
							uni.removeStorage({
								key: 'idCard'
							})
							uni.removeStorage({
								key: 's_mobile',
								success: (res) => {
									uni.navigateTo({
										url: "/pageBlank/components/cerficeSc"
									})
								}
							})
						} else {
							uni.hideLoading()
							uni.showToast({
								icon: 'none',
								title: res.msg
							})
						}
					})
				}else{
					uni.showToast({
						icon: 'none',
						title:"未同意协议，无法注销!"
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		width: 100%;
		height: 100%;

	}

	page-body {
		width: 100%;
		height: 100%;
	}

	.box {
		height: 100%;
		box-sizing: border-box;
		padding-top: 49rpx;

		.xieyi {
			position: fixed;
			bottom: 374rpx;
			display: flex;
			padding-left: 96rpx;
			box-sizing: border-box;
			align-items: center;

			.one {
				font-size: 26rpx;
				font-family: Segoe UI-Regular, Segoe UI;
				font-weight: 400;
				color: #475263;
			}

			.two {
				font-size: 26rpx;
				font-family: SFProText-Semibold-, SFProText-Semibold;
				font-weight: normal;
				color: #3F9BFB;
			}

			.crcle2 {
				margin-top: 5rpx;
				box-sizing: border-box;
				width: 30rpx;
				height: 30rpx;
				border-radius: 50%;
				opacity: 1;
				border: 8rpx solid #3478F5;
				margin-right: 8rpx;
			}

			.crcle {
				margin-top: 5rpx;
				width: 26rpx;
				height: 26rpx;
				opacity: 1;
				border-radius: 50%;
				border: 1rpx solid #3478F5;
				margin-right: 8rpx;
			}
		}


		.tips {
			height: 58rpx;
			line-height: 58rpx;
			font-size: 40rpx;
			font-family: Source Han Sans CN-Medium, Source Han Sans CN;
			font-weight: 500;
			color: #020202;
			margin-left: 45rpx;
			margin-bottom: 62rpx;
		}

		.txt {
			margin: 0 auto;
			width: 667rpx;
			height: 292rpx;
			background: #F9F9F9;
			border-radius: 18rpx 18rpx 18rpx 18rpx;
			opacity: 1;
			display: flex;
			flex-direction: column;
			padding: 36rpx;
			box-sizing: border-box;

			.send {
				display: flex;
				font-size: 28rpx;
				font-family: Source Han Sans CN-Regular, Source Han Sans CN;
				font-weight: 400;
				color: #2A2A2A;
				margin-bottom: 30rpx;
			}

			.fend {
				margin-left: 22rpx;
				font-size: 28rpx;
				font-family: Source Han Sans CN-Regular, Source Han Sans CN;
				font-weight: 400;
				color: #DF3A3A;
			}
		}

		.warn {
			width: 650rpx;
			display: flex;
			margin: 0 auto;
			margin-top: 42rpx;

			.img {
				margin-top: 15rpx;
				margin-right: 11rpx;
				width: 40rpx;
				height: 40rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.right {
				width: 600rpx;
				font-size: 24rpx;
				font-family: Source Han Sans CN-Light, Source Han Sans CN;
				font-weight: 300;
				color: #DF3A3A;
			}
		}

		.btn {
			// margin-top: 527rpx;
			width: 100%;
			position: fixed;
			bottom: 226rpx;

			.reallyBtn {
				width: 660rpx;
				margin: 0 auto;
				// margin-bottom: 226rpx;
				text-align: center;
				height: 88rpx;
				line-height: 88rpx;
				background: #F9F9F9;
				border-radius: 44rpx 44rpx 44rpx 44rpx;
				opacity: 1;
				font-size: 32rpx;
				font-family: Source Han Sans CN-Light, Source Han Sans CN;
				font-weight: 300;
				color: #ACACAC;
			}

			.checkBtn {
				width: 660rpx;
				margin: 0 auto;
				text-align: center;
				height: 88rpx;
				line-height: 88rpx;
				background: #3478F5;
				border-radius: 44rpx 44rpx 44rpx 44rpx;
				opacity: 1;
				font-size: 32rpx;
				font-family: Source Han Sans CN-Light, Source Han Sans CN;
				font-weight: 300;
				color: #FFFFFF;
			}
		}
	}
</style>
